#pragma once
#ifndef CLIB_clib_H
#define CLIB_clib_H

#include "clib_type.h"
#include "clib_driver.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef enum
{
   IFACE_TYPE_UNKNOWN  = 0, ///<Unknown interface type
   IFACE_TYPE_ETHERNET = 1, ///<Ethernet interface
   IFACE_TYPE_PPP      = 2, ///<PPP interface
   IFACE_TYPE_IPV4     = 3, ///<IPv4 interface
   IFACE_TYPE_IPV6     = 4, ///<IPv6 interface
   IFACE_TYPE_6LOWPAN  = 4, ///<6LoWPAN interface
   IFACE_TYPE_LOOPBACK = 5  ///<Loopback interface
} iface_type_e;

typedef enum
{
   IFACE_LINK_STATE_DOWN = 0,
   IFACE_LINK_STATE_UP   = 1,
   IFACE_LINK_STATE_AUTO = 2
} link_state_e;


typedef enum
{
   IFACE_LINK_SPEED_UNKNOWN = 0,
   IFACE_LINK_SPEED_10MBPS  = 10000000,
   IFACE_LINK_SPEED_100MBPS = 100000000,
   IFACE_LINK_SPEED_1GBPS   = 1000000000
} iface_speed_e;

typedef enum
{
   IFACE_UNKNOWN_DUPLEX_MODE = 0,
   IFACE_HALF_DUPLEX_MODE    = 1,
   IFACE_FULL_DUPLEX_MODE    = 2
} iface_mode_e;


typedef struct clib_iface_t
{
   void*             driver;
   u08_t             name[16];
   iface_type_e      type;
   iface_mode_e      mode;
   i32_t             mtu;
   iface_speed_e     link_speed;
   iface_speed_e     nic_speed;
   
   u32_t             ipv4;
   u32_t             ipv4_mask;
   u32_t             ipv4_gw;
   
   u32_t             ipv6[4];
   u32_t             ipv6_mask[4];
   u32_t             ipv6_gw[4];

   u32_t             max_que;
   u32_t             use_que;

   u64_t             rx[64];
   u64_t             tx[64];

} clib_iface_t;

void iface_name_set(clib_iface_t* iface,const i08_t* name);

void iface_type_set(clib_iface_t* iface, iface_type_e type);

void iface_mtu_set(clib_iface_t* iface, i32_t mtu);

void iface_speed_set(clib_iface_t* iface, iface_speed_e speed);

void iface_ipv4_set(clib_iface_t* iface,u32_t ipv4, u32_t mask,u32_t gate);

void iface_ipv6_set(clib_iface_t* iface,u32_t *ipv6,u32_t *mask,u32_t *gate);

void iface_driver_set(clib_iface_t* iface,void* drive);

void iface_offload_set(clib_iface_t* iface,u64_t offload);

u64_t iface_offload_get(clib_iface_t* iface);

void iface_pktlen_set(clib_iface_t* iface,u32_t len);

#ifdef __cplusplus
}
#endif

#endif